<template>
  <div>
    <el-form :inline="true">
      <el-form-item>
        <el-button type="primary" @click="addMenu">新增</el-button>
      </el-form-item>
    </el-form>
    <el-table
      :data="tableData"
      style="width: 100%;margin-bottom: 20px;"
      row-key="id"
      border default-expand-all
      :tree-props="{children: 'children', hasChildren: 'hasChildren'}">
      <el-table-column
          prop="name"
          label="名称"
          sortable width="180">
      </el-table-column>
      <el-table-column
          prop="perms"
          label="权限编码"
          sortable width="180">
      </el-table-column>
       <el-table-column
          prop="icon"
          label="图标">
      </el-table-column>
       <el-table-column
          prop="type"
          label="类型">
          <template slot-scope="scope">
            <el-tag size="small" v-if="scope.row.type === 0">目录</el-tag>
            <el-tag size="small" v-else-if="scope.row.type === 1" type="success">菜单</el-tag>
            <el-tag size="small" v-else-if="scope.row.type === 2" type="info">按钮</el-tag>
          </template>
      </el-table-column>
       <el-table-column
          prop="path"
          label="菜单URL"
          sortable width="180">
      </el-table-column>
       <el-table-column
          prop="component"
          label="菜单组件"
          sortable width="180">
      </el-table-column>
       <el-table-column
          prop="orderNum"
          label="排序号">
      </el-table-column>
       <el-table-column
          prop="statue"
          label="状态">
          <template slot-scope="scope">
            <el-tag size="small" v-if="scope.row.statue === 1" type="success">正常</el-tag>
            <el-tag size="small" v-else-if="scope.row.statue === 0" type="danger">禁用</el-tag>
          </template>
      </el-table-column>
        <el-table-column
          prop="operation"
          label="操作">
           <template slot-scope="scope">
            <el-button type="text" @click.native="dialogVisible = true" >编辑</el-button>
            <el-divider direction="vertical"></el-divider>
            <el-button type="text">删除</el-button>
          </template>
      </el-table-column>
    </el-table>

    <el-dialog
      title="提示"
      :visible.sync="dialogVisible"
      width="30%"
      :before-close="handleClose">
      <el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="100px" class="demo-ruleForm">
  <el-form-item label="活动名称" prop="name">
    <el-input v-model="ruleForm.name"></el-input>
  </el-form-item>
  <el-form-item label="活动区域" prop="region">
    <el-select v-model="ruleForm.region" placeholder="请选择活动区域">
      <el-option label="区域一" value="shanghai"></el-option>
      <el-option label="区域二" value="beijing"></el-option>
    </el-select>
  </el-form-item>
  <el-form-item label="活动时间" required>
    <el-col :span="11">
      <el-form-item prop="date1">
        <el-date-picker type="date" placeholder="选择日期" v-model="ruleForm.date1" style="width: 100%;"></el-date-picker>
      </el-form-item>
    </el-col>
    <el-col class="line" :span="2">-</el-col>
    <el-col :span="11">
      <el-form-item prop="date2">
        <el-time-picker placeholder="选择时间" v-model="ruleForm.date2" style="width: 100%;"></el-time-picker>
      </el-form-item>
    </el-col>
  </el-form-item>
  <el-form-item label="即时配送" prop="delivery">
    <el-switch v-model="ruleForm.delivery"></el-switch>
  </el-form-item>
  <el-form-item label="活动性质" prop="type">
    <el-checkbox-group v-model="ruleForm.type">
      <el-checkbox label="美食/餐厅线上活动" name="type"></el-checkbox>
      <el-checkbox label="地推活动" name="type"></el-checkbox>
      <el-checkbox label="线下主题活动" name="type"></el-checkbox>
      <el-checkbox label="单纯品牌曝光" name="type"></el-checkbox>
    </el-checkbox-group>
  </el-form-item>
  <el-form-item label="特殊资源" prop="resource">
    <el-radio-group v-model="ruleForm.resource">
      <el-radio label="线上品牌商赞助"></el-radio>
      <el-radio label="线下场地免费"></el-radio>
    </el-radio-group>
  </el-form-item>
  <el-form-item label="活动形式" prop="desc">
    <el-input type="textarea" v-model="ruleForm.desc"></el-input>
  </el-form-item>
  <el-form-item>
    <el-button type="primary" @click="submitForm('ruleForm')">立即创建</el-button>
    <el-button @click="resetForm('ruleForm')">重置</el-button>
  </el-form-item>
</el-form>
    </el-dialog>

  </div>
</template>
<script>
export default {
  name: 'Menu',
  data () {
    return {
      dialogVisible: false,
      tableData: [
        {
          id: 1,
          date: '2016-05-02',
          name: '王小虎1',
          type: 1,
          address: '上海市普陀区金沙江路 1518 弄',
          statue: 0
        },
        {
          id: 2,
          date: '2016-05-04',
          name: '王小虎2',
          type: 2,
          statue: 0,
          address: '上海市普陀区金沙江路 1517 弄'
        },
        {
          id: 3,
          date: '2016-05-01',
          name: '王小虎3',
          type: 0,
          statue: 1,
          address: '上海市普陀区金沙江路 1519 弄',
          children: [{
            id: 31,
            date: '2016-05-01',
            name: '王小虎',
            type: 0,
            statue: 1,
            address: '上海市普陀区金沙江路 1519 弄'
          }, {
            id: 32,
            date: '2016-05-01',
            name: '王小虎',
            type: 0,
            statue: 1,
            address: '上海市普陀区金沙江路 1519 弄'
          }]
        },
        {
          id: 4,
          date: '2016-05-03',
          name: '王小虎',
          statue: 1,
          type: 2,
          address: '上海市普陀区金沙江路 1516 弄'
        }]
    }
  },
  methods: {
    handleClose (done) {
      this.$confirm('确认关闭？')
        .then(_ => {
          done()
        })
        .catch(_ => {})
    }
  }
}

</script>
<style scoped>

</style>
